
* Generate weights

	gen partyID_merged_Dem = (partyID_merged==0)
	gen partyID_merged_Rep = (partyID_merged==1)
	gen partyID_merged_Ind = (partyID_merged==2)
	
	
	logit non_attrition_endline1 i.treat_control_type_study2##i.partyID_merged##i.BA_listserv i.treat_control_type_study2##i.BA_listserv##i.previous_BA_any i.treat_control_type_study2##i.partyID_merged##i.previous_BA_any if forced_type==0
		predict type_fit
			gen type_ipw = 1/type_fit		

/**************************
*
* DW vs. SBD with weights *
*
**************************/

	* Affective polarization (by type, with IPW, out-party animus only)

* Model results in Appendix Table A.8 (Appendix p. 16)
*p-value reported in text on page 20
		reg aff_pol_idx_noneg_out i.treat_control_type_study2 i.partyID_merged BA_listserv if forced_type==0 [pweight = type_ipw]
test 1.treat_control_type_study2=2.treat_control_type_study2
			margins, dydx(i.treat_control_type_study2)
				matrix aff_pol_idx_noneg_out = r(table)
					matselrc aff_pol_idx_noneg_out aff_pol_idx_noneg_out_sbd, r(1, 5, 6) c(2)
					matselrc aff_pol_idx_noneg_out aff_pol_idx_noneg_out_dw, r(1, 5, 6) c(3)

*Figure 2, Left panel (p. 20):										
				graph set window fontface "Times"
				coefplot (matrix(aff_pol_idx_noneg_out_sbd[1,]), ci((aff_pol_idx_noneg_out_sbd[2,] aff_pol_idx_noneg_out_sbd[3,])) recast(scatter) ciopts(lcolor(black) lpattern(solid)) mcolor(black) msymbol(square)) ///
					(matrix(aff_pol_idx_noneg_out_dw[1,]), ci((aff_pol_idx_noneg_out_dw[2,] aff_pol_idx_noneg_out_dw[3,])) recast(scatter) ciopts(lcolor(black) lpattern(longdash)) mcolor(black) msymbol(triangle)), ///
						name(aff_pol_idx_noneg_out_bytype, replace) scheme(plotplain) ///
						xtitle("Treatment effect on affective polarization (out-party animus only)", margin(medsmall)) xlabel(-1(.25)1, nogrid) ///
						ytitle("", margin(medsmall)) ylabel(, nogrid notick nolabels) ///
						legend(on nostack position(6) cols(3)order(2 "Skills for Bridging the Divide" 4 "Depolarizing Within")) ///
						xline(0, lcolor(black) lpattern(dash)) 

	* Affective polarization (by type, with IPW)

* Model results in Appendix Table A.9 (Appendix p. 17)
		reg aff_pol_idx_noneg i.treat_control_type_study2 i.partyID_merged BA_listserv if forced_type==0 [pweight = type_ipw]
test 1.treat_control_type_study2=2.treat_control_type_study2
			margins, dydx(i.treat_control_type_study2)
				matrix aff_pol_idx_noneg = r(table)
					matselrc aff_pol_idx_noneg aff_pol_idx_noneg_sbd, r(1, 5, 6) c(2)
					matselrc aff_pol_idx_noneg aff_pol_idx_noneg_dw, r(1, 5, 6) c(3)

*Figure 2, Right panel (p. 20)
				graph set window fontface "Times"
				coefplot (matrix(aff_pol_idx_noneg_sbd[1,]), ci((aff_pol_idx_noneg_sbd[2,] aff_pol_idx_noneg_sbd[3,])) recast(scatter) ciopts(lcolor(black) lpattern(solid)) mcolor(black) msymbol(square)) ///
					(matrix(aff_pol_idx_noneg_dw[1,]), ci((aff_pol_idx_noneg_dw[2,] aff_pol_idx_noneg_dw[3,])) recast(scatter) ciopts(lcolor(black) lpattern(longdash)) mcolor(black) msymbol(triangle)), ///
						name(aff_pol_idx_noneg_bytype, replace) scheme(plotplain) ///
						xtitle("Treatment effect on affective polarization", margin(medsmall)) xlabel(-1(.25)1, nogrid) ///
						ytitle("", margin(medsmall)) ylabel(, nogrid notick nolabels) ///
						legend(on nostack position(6) cols(3)order(2 "Skills for Bridging the Divide" 4 "Depolarizing Within")) ///
						xline(0, lcolor(black) lpattern(dash)) 

*Full Figure 2 (p. 20)					
		grc1leg aff_pol_idx_noneg_out_bytype aff_pol_idx_noneg_bytype, scale(1.4)  ycommon scheme(plotplain) col(2)  name(aff_pol_idx, replace) ///
			title("")
		graph display aff_pol_idx, xsize(15) ysize(5)	
					
				graph export "Output/aff_pol_idx_bytype_IPW_1.pdf", as(pdf) replace
				
				
	* Affective polarization (by type, with IPW, out-party animus only, no independents)

		reg aff_pol_idx_noneg_out i.treat_control_type_study2 i.partyID_merged BA_listserv if forced_type==0 & partyID_merged!=2 [pweight = type_ipw]
test 1.treat_control_type_study2=2.treat_control_type_study2
			margins, dydx(i.treat_control_type_study2)
				matrix aff_pol_idx_noneg_out = r(table)
					matselrc aff_pol_idx_noneg_out aff_pol_idx_noneg_out_sbd, r(1, 5, 6) c(2)
					matselrc aff_pol_idx_noneg_out aff_pol_idx_noneg_out_dw, r(1, 5, 6) c(3)

*Appendix Figure A.3, Left panel (appendix p. 18)
				graph set window fontface "Times"
				coefplot (matrix(aff_pol_idx_noneg_out_sbd[1,]), ci((aff_pol_idx_noneg_out_sbd[2,] aff_pol_idx_noneg_out_sbd[3,])) recast(scatter) ciopts(lcolor(black) lpattern(solid)) mcolor(black) msymbol(square)) ///
					(matrix(aff_pol_idx_noneg_out_dw[1,]), ci((aff_pol_idx_noneg_out_dw[2,] aff_pol_idx_noneg_out_dw[3,])) recast(scatter) ciopts(lcolor(black) lpattern(longdash)) mcolor(black) msymbol(triangle)), ///
						name(aff_pol_idx_noneg_out_bytype, replace) scheme(plotplain) ///
						xtitle("Treatment effect on affective polarization (out-party animus only)", margin(medsmall)) xlabel(-1(.25)1, nogrid) ///
						ytitle("", margin(medsmall)) ylabel(, nogrid notick nolabels) ///
						legend(on nostack position(6) cols(3)order(2 "Skills for Bridging the Divide" 4 "Depolarizing Within")) ///
						xline(0, lcolor(black) lpattern(dash)) 

	* Affective polarization (by type, with IPW, no independents)

		reg aff_pol_idx_noneg i.treat_control_type_study2 i.partyID_merged BA_listserv if forced_type==0  & partyID_merged!=2 [pweight = type_ipw]
test 1.treat_control_type_study2=2.treat_control_type_study2
			margins, dydx(i.treat_control_type_study2)
				matrix aff_pol_idx_noneg = r(table)
					matselrc aff_pol_idx_noneg aff_pol_idx_noneg_sbd, r(1, 5, 6) c(2)
					matselrc aff_pol_idx_noneg aff_pol_idx_noneg_dw, r(1, 5, 6) c(3)

*Appendix Figure A.3, Right panel (appendix p. 18)
				graph set window fontface "Times"
				coefplot (matrix(aff_pol_idx_noneg_sbd[1,]), ci((aff_pol_idx_noneg_sbd[2,] aff_pol_idx_noneg_sbd[3,])) recast(scatter) ciopts(lcolor(black) lpattern(solid)) mcolor(black) msymbol(square)) ///
					(matrix(aff_pol_idx_noneg_dw[1,]), ci((aff_pol_idx_noneg_dw[2,] aff_pol_idx_noneg_dw[3,])) recast(scatter) ciopts(lcolor(black) lpattern(longdash)) mcolor(black) msymbol(triangle)), ///
						name(aff_pol_idx_noneg_bytype, replace) scheme(plotplain) ///
						xtitle("Treatment effect on affective polarization", margin(medsmall)) xlabel(-1(.25)1, nogrid) ///
						ytitle("", margin(medsmall)) ylabel(, nogrid notick nolabels) ///
						legend(on nostack position(6) cols(3)order(2 "Skills for Bridging the Divide" 4 "Depolarizing Within")) ///
						xline(0, lcolor(black) lpattern(dash)) 
*Full Appendix Figure A.3 (appendix p. 18)						
		grc1leg aff_pol_idx_noneg_out_bytype aff_pol_idx_noneg_bytype, scale(1.4)  ycommon scheme(plotplain) col(2)  name(aff_pol_idx, replace) ///
			title("")
		graph display aff_pol_idx, xsize(15) ysize(5)	
					
				graph export "Output/aff_pol_idx_bytype_noInd_IPW_1.pdf", as(pdf) replace
			
				
				
	* Affective polarization (by type, robustness to no weights and different weights)
*Appendix Table A.9 (appendix p. 17)
	
preserve 

	logit non_attrition_endline1 i.treat_control_type_study2##i.partyID_merged i.treat_control_type_study2##i.BA_listserv i.treat_control_type_study2##i.previous_BA_any if forced_type==0
			predict type_fit2
			gen type_ipw2 = 1/type_fit2
	logit non_attrition_endline1 i.treat_control_type_study2##i.partyID_merged##i.BA_listserv##i.previous_BA_any if forced_type==0
		predict type_fit4
			gen type_ipw4 = 1/type_fit4

label var BA_listserv "Recruited from BA listserv"

label define partyID_merged 0 "Democrats" 1 "Republicans" 2 "Independents"
label values partyID_merged partyID_merged

label var treat_sbd_mix "Mixed SBD" 
label var treat_dw_mix "Mixed DW" 
label var treat_sbd_hom_blue "Homogeneous SBD" 
label var treat_dw_hom_blue "Homogeneous DW"
			
		eststo affpol_main: reg aff_pol_idx_noneg i.treat_control_type_study2 i.partyID_merged BA_listserv if forced_type==0 [pweight = type_ipw]
		eststo affpol_noweights: reg aff_pol_idx_noneg i.treat_control_type_study2 i.partyID_merged BA_listserv if forced_type==0 
		eststo affpol_w2: reg aff_pol_idx_noneg i.treat_control_type_study2 i.partyID_merged BA_listserv if forced_type==0 [pweight = type_ipw2]
		eststo affpol_w4: reg aff_pol_idx_noneg i.treat_control_type_study2 i.partyID_merged BA_listserv if forced_type==0 [pweight = type_ipw4]
		eststo affpol_dems: reg aff_pol_idx_noneg i.treat_control_type_study2 i.partyID_merged BA_listserv if forced_type==0 & partyID_merged==0
		eststo affpol_typecomp: reg aff_pol_idx_noneg treat_sbd_mix treat_dw_mix treat_sbd_hom_blue treat_dw_hom_blue BA_listserv if forced_type==0 & forced_comp==0
		
	
		esttab affpol_main affpol_w* affpol_noweights affpol_dems affpol_typecomp using "Output/affpol_bytype_diffweights.tex", replace ///
			label booktabs b(3) se(3) eqlabels(none) br nonotes nocons star(* 0.10 ** 0.05 *** 0.01) ///
			collabels(none) mtitles("IPW Main" "IPW2" "IPW4" "No weights" "Dems Only" "Dems Only") drop(0.treat_control_type_study2 0.partyID_merged)


	* Outparty Animus (by type, robustness to no weights and different weights)
*Appendix table A.8 (appendix p. 16)	

		eststo affpol_out_main: reg aff_pol_idx_noneg_out i.treat_control_type_study2 i.partyID_merged BA_listserv if forced_type==0 [pweight = type_ipw]
		eststo affpol_out_noweights: reg aff_pol_idx_noneg_out i.treat_control_type_study2 i.partyID_merged BA_listserv if forced_type==0 
		eststo affpol_out_w2: reg aff_pol_idx_noneg_out i.treat_control_type_study2 i.partyID_merged BA_listserv if forced_type==0 [pweight = type_ipw2]
		eststo affpol_out_w4: reg aff_pol_idx_noneg_out i.treat_control_type_study2 i.partyID_merged BA_listserv if forced_type==0 [pweight = type_ipw4]
		eststo affpol_out_dems: reg aff_pol_idx_noneg_out i.treat_control_type_study2 i.partyID_merged BA_listserv if forced_type==0 & partyID_merged==0
		eststo affpol_out_typecomp: reg aff_pol_idx_noneg_out treat_sbd_mix treat_dw_mix treat_sbd_hom_blue treat_dw_hom_blue BA_listserv if forced_type==0 & forced_comp==0
		
		esttab affpol_out_main affpol_out_w* affpol_out_noweights affpol_out_dems affpol_out_typecomp using "Output/affpol_out_bytype_diffweights.tex", replace ///
			label booktabs b(3) se(3) eqlabels(none) br nonotes nocons star(* 0.10 ** 0.05 *** 0.01) ///
			collabels(none) mtitles("IPW Main" "IPW2" "IPW4" "No weights" "Dems Only" "Dems Only") drop(0.treat_control_type_study2 0.partyID_merged)

restore 

		* Generate extreme value versions of affective polarization and outparty animus

*Appendix table A.12 (appendix p. 20)

tab attrit treat_control_type_study2, col // there are 22 people more attriting from SBD compared to Control (if each were to have a 44% attrition rate)

preserve 
		la var BA_listserv "Recruited from BA listserv"
		label define partyID_merged 0 "Democrats" 1 "Republicans" 2 "Independents"
		label values partyID_merged partyID_merged

set seed 04142023
	gen aff_pol_idx_noneg_low = aff_pol_idx_noneg
	gen rand=runiform() if treat_control_type_study2==1 & aff_pol_idx_noneg_low==. & forced_type==0
	sort rand
	gen nrand=_n
		sum aff_pol_idx_noneg if treat_control_type_study2==0, d
			replace aff_pol_idx_noneg_low = r(p25) if treat_control_type_study2==1 & aff_pol_idx_noneg_low==. & _n<=22
			
	gen aff_pol_idx_noneg_out_low = aff_pol_idx_noneg_out
	gen rand_out=runiform() if treat_control_type_study2==1 & aff_pol_idx_noneg_out_low==. & forced_type==0
	sort rand_out
	gen nrand_out=_n
		sum aff_pol_idx_noneg_out if treat_control_type_study2==0, d
			replace aff_pol_idx_noneg_out_low = r(p25) if treat_control_type_study2==1 & aff_pol_idx_noneg_out_low==. & _n<=22

	eststo aff_pol_idx_noneg_25: reg aff_pol_idx_noneg_low i.treat_control_type_study2 i.partyID_merged BA_listserv if forced_type==0
	eststo aff_pol_idx_noneg_out_25: reg aff_pol_idx_noneg_out_low i.treat_control_type_study2 i.partyID_merged BA_listserv if forced_type==0
	
drop aff_pol_idx_noneg_low aff_pol_idx_noneg_out_low rand nrand rand_out nrand_out
	gen rand=runiform() if treat_control_type_study2==1 & aff_pol_idx_noneg==. & forced_type==0
	sort rand
	gen nrand=_n
	gen aff_pol_idx_noneg_low = aff_pol_idx_noneg
		sum aff_pol_idx_noneg if treat_control_type_study2==0, d
			replace aff_pol_idx_noneg_low = r(p10) if treat_control_type_study2==1 & aff_pol_idx_noneg_low==. & _n<=22
			
	gen rand_out=runiform() if treat_control_type_study2==1 & aff_pol_idx_noneg_out==. & forced_type==0
	sort rand_out
	gen nrand_out=_n
	gen aff_pol_idx_noneg_out_low = aff_pol_idx_noneg_out
		sum aff_pol_idx_noneg_out if treat_control_type_study2==0, d
			replace aff_pol_idx_noneg_out_low = r(p10) if treat_control_type_study2==1 & aff_pol_idx_noneg_out_low==. & _n<=22

	eststo aff_pol_idx_noneg_10: reg aff_pol_idx_noneg_low i.treat_control_type_study2 i.partyID_merged BA_listserv if forced_type==0
	eststo aff_pol_idx_noneg_out_10: reg aff_pol_idx_noneg_out_low i.treat_control_type_study2 i.partyID_merged BA_listserv if forced_type==0
	
	
			esttab aff_pol_idx_noneg_25 aff_pol_idx_noneg_out_25 aff_pol_idx_noneg_10 aff_pol_idx_noneg_out_10 using "Output/bounding.tex", replace ///
			label booktabs b(3) se(3) eqlabels(none) br nonotes nocons star(* 0.10 ** 0.05 *** 0.01) ///
			collabels(none) mtitles("\shortstack{Affective \\ polarization}" "\shortstack{Affective \\ polarization (out- \\ party animus only)}" "\shortstack{Affective \\ polarization}" "\shortstack{Affective \\ polarization (out- \\ party animus only)}") drop(0.treat_control_type_study2 0.partyID_merged) ///
			mgroups("\shortstack{Attriters assigned to \\ the 25th percentile}" "\shortstack{Attriters assigned to \\ the 10th percentile}", pattern(1 0 1 0) ///
			prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))


restore
			
	* Compliance by type and composition
	
	*Appendix Table A.2 (appendix p. 9)
		
		eststo complier_treat_type: reg complier i.treat_control_type_study2 if forced_type==0 
			estadd local F_stat = round(e(F),.001)	
			test 1.treat_control=2.treat_control
		eststo complier_treat_comp: reg complier i.treat_control_comp_study2 if forced_comp==0 
			estadd local F_stat = round(e(F),.001)	
			test 1.treat_control=2.treat_control
		
		esttab complier_treat_type complier_treat_comp using "Output/complier_bytypecomp.tex", replace ///
			label booktabs b(3) se(3) eqlabels(none) br nonotes nocons star(* 0.10 ** 0.05 *** 0.01) ///
			nomtitle collabels(none) drop(0.treat_control_comp_study2 0.treat_control_type_study2)  mgroups("Complier", pattern(1 0 0) ///
			prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) 


				* Attendance by workshop type
				
	*Appendix Table A.3 (appendix p. 9)
	
		preserve
	
		la var treat_control_sbd_study2 "Assigned to SBD Workshop"
		la var treat_control_dw_study2 "Assigned to DW Workshop"

		eststo attend_sbd: reg attend_sbd treat_control_sbd_study2
		eststo attend_dw: reg attend_dw treat_control_dw_study2
		
		esttab attend_sbd attend_dw using "Output/attend_bytype.tex", replace ///
			label booktabs b(3) se(3) eqlabels(none) br nonotes nocons star(* 0.10 ** 0.05 *** 0.01) ///
			collabels(none) mtitles("Attended SBD Workshop" "Attended DW Workshop") ///
			scalar(F)

restore
			
	*CACE for Affective Polarization and Outparty Animus by type
	
*Appendix Table A.4 (appendix p. 10)	
	
		preserve
	
		la var attend_sbd "Attended SBD Workshop"
		la var attend_dw "Attended DW Workshop"
		la var BA_listserv "Recruited from BA listserv"
		label define partyID_merged 0 "Democrats" 1 "Republicans" 2 "Independents"
		label values partyID_merged partyID_merged

		*coefficient and p-value in text, appendix p. 10		
		eststo IV_ITT: ivregress 2sls aff_pol_idx_noneg BA_listserv i.partyID_merged (attend_sbd attend_dw =  treat_control_sbd_study2  treat_control_dw_study2) if forced_type==0 [pweight=type_ipw]	

		*coefficient and p-value in text, appendix p. 10	
		eststo IV_ITT_out: ivregress 2sls aff_pol_idx_noneg_out BA_listserv i.partyID_merged (attend_sbd attend_dw =  treat_control_sbd_study2  treat_control_dw_study2) if forced_type==0 [pweight=type_ipw]	


		esttab IV_ITT IV_ITT_out using "Output/aff_pol_idx_noneg_CACE_bytype.tex", replace ///
			label booktabs b(3) se(3) eqlabels(none) br nonotes nocons star(* 0.10 ** 0.05 *** 0.01) ///
			drop(0.partyID_merged) collabels(none) mtitles("\shortstack{Affective \\ polarization}" "\shortstack{Affective \\ polarization (out- \\ party animus only)}")

		restore

			
	* Affective polarization (by component and by type, with IPW)

*Appendix Figure A.4 (appendix p. 21)

		reg therm_inparty i.treat_control_type_study2 i.partyID_merged BA_listserv if forced_type==0 [pweight = type_ipw]
			margins, dydx(i.treat_control_type_study2)
				matrix therm_inparty = r(table)
					matselrc therm_inparty therm_inparty_sbd, r(1, 5, 6) c(2)
					matselrc therm_inparty therm_inparty_dw, r(1, 5, 6) c(3)
		
				graph set window fontface "Times"
				coefplot (matrix(therm_inparty_sbd[1,]), ci((therm_inparty_sbd[2,] therm_inparty_sbd[3,])) recast(scatter) ciopts(lcolor(black) lpattern(solid)) mcolor(black) msymbol(square)) ///
					(matrix(therm_inparty_dw[1,]), ci((therm_inparty_dw[2,] therm_inparty_dw[3,])) recast(scatter) ciopts(lcolor(black) lpattern(longdash)) mcolor(black) msymbol(triangle)), ///
						name(therm_inparty_bytype, replace) scheme(plotplain) ///
						xtitle("Treatment effect on in-party warmth", margin(medsmall)) xlabel(-15(5)15, nogrid) ///
						ytitle("", margin(medsmall)) ylabel(, nogrid notick nolabels) ///
						legend(on nostack position(6) cols(3)order(2 "Skills for Bridging the Divide" 4 "Depolarizing Within")) ///
						xline(0, lcolor(black) lpattern(dash)) 

		reg therm_outparty i.treat_control_type_study2 i.partyID_merged BA_listserv if forced_type==0 [pweight = type_ipw]
			margins, dydx(i.treat_control_type_study2)
				matrix therm_outparty = r(table)
					matselrc therm_outparty therm_outparty_sbd, r(1, 5, 6) c(2)
					matselrc therm_outparty therm_outparty_dw, r(1, 5, 6) c(3)
		
				graph set window fontface "Times"
				coefplot (matrix(therm_outparty_sbd[1,]), ci((therm_outparty_sbd[2,] therm_outparty_sbd[3,])) recast(scatter) ciopts(lcolor(black) lpattern(solid)) mcolor(black) msymbol(square)) ///
					(matrix(therm_outparty_dw[1,]), ci((therm_outparty_dw[2,] therm_outparty_dw[3,])) recast(scatter) ciopts(lcolor(black) lpattern(longdash)) mcolor(black) msymbol(triangle)), ///
						name(therm_outparty_bytype, replace) scheme(plotplain) ///
						xtitle("Treatment effect on out-party warmth", margin(medsmall)) xlabel(-15(5)15, nogrid) ///
						ytitle("", margin(medsmall)) ylabel(, nogrid notick nolabels) ///
						legend(on nostack position(6) cols(3)order(2 "Skills for Bridging the Divide" 4 "Depolarizing Within")) ///
						xline(0, lcolor(black) lpattern(dash)) 

		reg trust_inparty i.treat_control_type_study2 i.partyID_merged BA_listserv if forced_type==0 [pweight = type_ipw]
			margins, dydx(i.treat_control_type_study2)
				matrix trust_inparty = r(table)
					matselrc trust_inparty trust_inparty_sbd, r(1, 5, 6) c(2)
					matselrc trust_inparty trust_inparty_dw, r(1, 5, 6) c(3)
		
				graph set window fontface "Times"
				coefplot (matrix(trust_inparty_sbd[1,]), ci((trust_inparty_sbd[2,] trust_inparty_sbd[3,])) recast(scatter) ciopts(lcolor(black) lpattern(solid)) mcolor(black) msymbol(square)) ///
					(matrix(trust_inparty_dw[1,]), ci((trust_inparty_dw[2,] trust_inparty_dw[3,])) recast(scatter) ciopts(lcolor(black) lpattern(longdash)) mcolor(black) msymbol(triangle)), ///
						name(trust_inparty_bytype, replace) scheme(plotplain) ///
						xtitle("Treatment effect on in-party trust", margin(medsmall)) xlabel(-.5(.25).5, nogrid) ///
						ytitle("", margin(medsmall)) ylabel(, nogrid notick nolabels) ///
						legend(on nostack position(6) cols(3)order(2 "Skills for Bridging the Divide" 4 "Depolarizing Within")) ///
						xline(0, lcolor(black) lpattern(dash)) 

		reg trust_outparty i.treat_control_type_study2 i.partyID_merged BA_listserv if forced_type==0 [pweight = type_ipw]
			margins, dydx(i.treat_control_type_study2)
				matrix trust_outparty = r(table)
					matselrc trust_outparty trust_outparty_sbd, r(1, 5, 6) c(2)
					matselrc trust_outparty trust_outparty_dw, r(1, 5, 6) c(3)
		
				graph set window fontface "Times"
				coefplot (matrix(trust_outparty_sbd[1,]), ci((trust_outparty_sbd[2,] trust_outparty_sbd[3,])) recast(scatter) ciopts(lcolor(black) lpattern(solid)) mcolor(black) msymbol(square)) ///
					(matrix(trust_outparty_dw[1,]), ci((trust_outparty_dw[2,] trust_outparty_dw[3,])) recast(scatter) ciopts(lcolor(black) lpattern(longdash)) mcolor(black) msymbol(triangle)), ///
						name(trust_outparty_bytype, replace) scheme(plotplain) ///
						xtitle("Treatment effect on out-party trust", margin(medsmall)) xlabel(-.5(.25).5, nogrid) ///
						ytitle("", margin(medsmall)) ylabel(, nogrid notick nolabels) ///
						legend(on nostack position(6) cols(3)order(2 "Skills for Bridging the Divide" 4 "Depolarizing Within")) ///
						xline(0, lcolor(black) lpattern(dash)) 
												
			graph combine therm_inparty_bytype trust_inparty_bytype, title(Perceptions of in-party) ycommon scheme(plotplain) col(1) name(inparty_bytype_combined, replace)
			graph combine therm_outparty_bytype trust_outparty_bytype, title(Perceptions of out-party) ycommon scheme(plotplain) col(1) name(outparty_bytype_combined, replace)
			graph combine inparty_bytype_combined outparty_bytype_combined, ycommon scheme(plotplain) col(2) name(inparty_outparty_bytype_combined, replace)
			
		
				graph export "Output/inparty_outparty_bytype_combined_1.pdf", as(pdf) replace

	* Affective polarization (by type and composition)
	
*Figure 3 (p. 23)	

		bytype_bycomp aff_pol_idx_noneg, ctrls(BA_listserv) condition(forced_type==0 & forced_comp==0) outcome(affective polarization) xmin(-1) xmax(1) xdelta(.25) wave(1)
		bytype_bycomp aff_pol_idx_noneg_out, ctrls(BA_listserv) condition(forced_type==0 & forced_comp==0) outcome(affective polarization (out-party animus only)) xmin(-1) xmax(1) xdelta(.25) wave(1)

			grc1leg aff_pol_idx_noneg_out aff_pol_idx_noneg , scale(.8) ycommon scheme(plotplain) col(2) name(aff_pol_idx_noneg_combined, replace)
				graph export "Output/aff_pol_idx_noneg_combined_1.pdf", as(pdf) replace
				
	* Affective polarization (by composition)
	
*Appendix Figure A.5 (appendix p. 22)	

		bycomp aff_pol_idx_noneg, ctrls(BA_listserv) condition(forced_comp==0) outcome(affective polarization) xmin(-.5) xmax(.5) xdelta(.25) wave(1)
		bycomp aff_pol_idx_noneg_out, ctrls(BA_listserv) condition(forced_comp==0) outcome(affective polarization (out-party animus only)) xmin(-.5) xmax(.5) xdelta(.25) wave(1)

			grc1leg aff_pol_idx_noneg_out_bycomp aff_pol_idx_noneg_bycomp , scale(.8) ycommon scheme(plotplain) col(2) name(aff_pol_idx_noneg_combined, replace)
				graph export "Output/aff_pol_idx_noneg_bycomp_combined_1.pdf", as(pdf) replace

				
	* Attrition by treatment assignment, by type and composition
	
	*Appendix Table A.1 (appendix p. 8)
	
		preserve
		
		gen treat_control_dw_study2_Dem = treat_control_dw_study2*partyID_merged_Dem
		gen treat_control_dw_study2_Rep = treat_control_dw_study2*partyID_merged_Rep
		gen treat_control_dw_study2_Ind = treat_control_dw_study2*partyID_merged_Ind
		gen treat_control_sbd_study2_Dem = treat_control_sbd_study2*partyID_merged_Dem
		gen treat_control_sbd_study2_Rep = treat_control_sbd_study2*partyID_merged_Rep
		gen treat_control_sbd_study2_Ind = treat_control_sbd_study2*partyID_merged_Ind
			
		la var attrition_endline1 "Attriter"
		la var treat_control_dw_study2 "Any DW"
		la var treat_control_sbd_study2 "Any SBD"
		la var treat_dw_hom_blue "Homogeneous DW"
		la var treat_dw_mix "Mixed DW"
		la var treat_sbd_hom_blue "Homogeneous SBD"
		la var treat_sbd_mix "Mixed SBD"
		la var partyID_merged_Dem "Democrat"
		la var partyID_merged_Rep "Republican"
		la var partyID_merged_Ind "Independent"
		la var treat_control_dw_study2_Dem "Any DW $\times$ Democrat"
		la var treat_control_dw_study2_Rep "Any DW $\times$ Republican"
		la var treat_control_dw_study2_Ind "Any DW $\times$ Independent"
		la var treat_control_sbd_study2_Dem "Any SBD $\times$ Democrat"
		la var treat_control_sbd_study2_Rep "Any SBD $\times$ Republican"
		la var treat_control_sbd_study2_Ind "Any SBD $\times$ Independent"
	
		eststo attrition_bytype: reg attrition_endline1 treat_control_dw_study2 treat_control_sbd_study2 if forced_type==0
	
		eststo attrition_bytype_bycomp: reg attrition_endline1 treat_dw_hom_blue treat_dw_mix treat_sbd_hom_blue treat_sbd_mix if forced_type==0 & forced_comp==0
		
		eststo attrition_bytype_bypartyID: reg attrition_endline1 treat_control_dw_study2 treat_control_sbd_study2 partyID_merged_Rep partyID_merged_Ind treat_control_sbd_study2_Rep treat_control_sbd_study2_Ind if forced_type==0
		
		eststo attrition_bytype_Dem: reg attrition_endline1 treat_control_dw_study2 treat_control_sbd_study2 if forced_type==0 & partyID_merged==0
		
		eststo attrition_bytype_Rep: reg attrition_endline1 treat_control_dw_study2 treat_control_sbd_study2 if forced_type==0 & partyID_merged==1

		eststo attrition_bytype_Ind: reg attrition_endline1 treat_control_dw_study2 treat_control_sbd_study2 if forced_type==0 & partyID_merged==2

		
		esttab attrition_bytype attrition_bytype_bycomp attrition_bytype_Dem attrition_bytype_Rep attrition_bytype_Ind using "Output/attrition_bytype_bycomp_1.tex", replace ///
			label booktabs b(3) se(3) eqlabels(none) br nonotes nocons star(* 0.10 ** 0.05 *** 0.01) mtitles("" "" "Democrats" "Republicans" "Independents") ///
			collabels(none) mgroups("Attriter", pattern(1 0 0) ///
			prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))

						
		restore
	
/*****
*
* DW *
*
******/

	* Social media engagement, DW only and DW by composition

*Figure 4 (p.24)


	
		DW_bycomp_combined any_social, ctrls(i.partyID_merged BA_listserv) newctrls(BA_listserv) outcome(any social media engagement) xmin(-.25) xmax(.25) xdelta(.05) wave(1)

						
	* Donations, DW only and DW by composition
	
	*Figure 5 (p. 26)
	*p-values in text on page 25 produced in the console output

		DW_bycomp_combined donate_total, ctrls(i.partyID_merged BA_listserv) newctrls(BA_listserv) outcome(all donations) xmin(-7.5) xmax(7.5) xdelta(2.5) wave(1)
		DW_bycomp_combined donate_ba, ctrls(i.partyID_merged BA_listserv) newctrls(BA_listserv) outcome(donations to BA) xmin(-7.5) xmax(7.5) xdelta(2.5) wave(1)
		DW_bycomp_combined donate_allsides, ctrls(i.partyID_merged BA_listserv) newctrls(BA_listserv)  outcome(donations to AllSides) xmin(-7.5) xmax(7.5) xdelta(2.5) wave(1)
		DW_bycomp_combined donate_lrc, ctrls(i.partyID_merged BA_listserv) newctrls(BA_listserv)  outcome(donations to LRC) xmin(-7.5) xmax(7.5) xdelta(2.5) wave(1)
					
			graph combine donate_total donate_ba donate_allsides donate_lrc, ycommon xcommon scheme(plotplain) col(2) name(donate_DW_bycomp_combined_1, replace)
				graph export "Output/donate_DW_bycomp_combined_1.pdf", as(pdf) replace
				
	* Registration for America Talks, DW only and DW by composition
	
	*Figure 6 (p. 27)

		DW_bycomp_combined answered_amtalks, ctrls(i.partyID_merged BA_listserv) newctrls(BA_listserv) outcome(registration for America Talks) xmin(-.5) xmax(.5) xdelta(.25) wave(1)
		*p-value reported in text on page 27
		test treat_dw_hom_blue=treat_dw_mix 
	*Appendix Figure A.6 (apendix p. 23)
		DW_bycomp_combined clicked_amtalks, ctrls(i.partyID_merged BA_listserv) newctrls(BA_listserv) outcome(clicks on America Talks) xmin(-.5) xmax(.5) xdelta(.25) wave(1)
		test treat_dw_hom_blue=treat_dw_mix
	*Appendix Figure A.7 (appendix p. 23)	
		DW_bycomp_combined attend_amtalks, ctrls(i.partyID_merged BA_listserv) newctrls(BA_listserv) outcome(attendance at America Talks) xmin(-.5) xmax(.5) xdelta(.25) wave(1)
		test treat_dw_hom_blue=treat_dw_mix		
						

	* Table for social media, donations and America Talks, DW only
	
	*Appendix Table A.10 (appendix p. 18)
	
label var BA_listserv "Recruited from BA listserv"

label define partyID_merged 0 "Democrats" 1 "Republicans" 2 "Independents"
label values partyID_merged partyID_merged

label var treat_control_dw_study2 "Any DW"
label var treat_sbd_mix "Mixed SBD" 
label var treat_dw_mix "Mixed DW" 
label var treat_sbd_hom_blue "Homogeneous SBD" 
label var treat_dw_hom_blue "Homogeneous DW"
	
	eststo dwonly_any_social: reg any_social treat_control_dw_study2 i.partyID_merged BA_listserv if forced_type==0 & treat_control_sbd_study2==0
	eststo dwonly_donate_total: reg donate_total treat_control_dw_study2 i.partyID_merged BA_listserv if forced_type==0 & treat_control_sbd_study2==0
	eststo dwonly_donate_ba: reg donate_ba treat_control_dw_study2 i.partyID_merged BA_listserv if forced_type==0 & treat_control_sbd_study2==0
	eststo dwonly_donate_allsides: reg donate_allsides treat_control_dw_study2 i.partyID_merged BA_listserv if forced_type==0 & treat_control_sbd_study2==0
	eststo dwonly_donate_lrc: reg donate_lrc treat_control_dw_study2 i.partyID_merged BA_listserv if forced_type==0 & treat_control_sbd_study2==0
	eststo dwonly_answered_amtalks: reg answered_amtalks treat_control_dw_study2 i.partyID_merged BA_listserv if forced_type==0 & treat_control_sbd_study2==0

		esttab dwonly_* using "Output/dwonly_secondary.tex", replace ///
			label booktabs b(3) se(3) eqlabels(none) br nonotes nocons star(* 0.10 ** 0.05 *** 0.01) ///
			collabels(none) mtitles("Social media" "All donations" "BA" "All Sides" "LRC" "America Talks") drop(0.partyID_merged)
			

	* Table for social media, donations and America Talks, DW by composition
	
*Appendix Table A.11 (appendix p. 19)
	
	eststo dwbycomp_any_social: reg any_social treat_dw_hom_blue treat_dw_mix BA_listserv if forced_type==0 & forced_comp==0 & treat_control_sbd_study2==0
	eststo dwbycomp_donate_total: reg donate_total treat_dw_hom_blue treat_dw_mix BA_listserv if forced_type==0 & forced_comp==0 & treat_control_sbd_study2==0
	eststo dwbycomp_donate_ba: reg donate_ba treat_dw_hom_blue treat_dw_mix BA_listserv if forced_type==0 & forced_comp==0 & treat_control_sbd_study2==0
	eststo dwbycomp_donate_allsides: reg donate_allsides treat_dw_hom_blue treat_dw_mix BA_listserv if forced_type==0 & forced_comp==0 & treat_control_sbd_study2==0
	eststo dwbycomp_donate_lrc: reg donate_lrc treat_dw_hom_blue treat_dw_mix BA_listserv if forced_type==0 & forced_comp==0 & treat_control_sbd_study2==0
	eststo dwbycomp_answered_amtalks: reg answered_amtalks treat_dw_hom_blue treat_dw_mix BA_listserv if forced_type==0 & forced_comp==0 & treat_control_sbd_study2==0
	
			esttab dwbycomp_* using "Output/dwbycomp_secondary.tex", replace ///
			label booktabs b(3) se(3) eqlabels(none) br nonotes nocons star(* 0.10 ** 0.05 *** 0.01) ///
			collabels(none) mtitles("Social media" "All donations" "BA" "All Sides" "LRC" "America Talks") 
			

	* Attrition by treatment assignment, DW only and DW by composition
	
		preserve
	
		gen treat_control_study2_BA_listserv = treat_control_study2*BA_listserv
	
		la var treat_control_dw_study2 "Assigned to any DW"
		la var treat_dw_hom_blue "Assigned to homogeneous DW"
		la var treat_dw_mix "Assigned to mixed DW"
		la var attrition_endline1 "Attriter"
	
		eststo attrition_DW: reg attrition_endline1 treat_control_dw_study2 if forced_type==0 & treat_control_sbd_study2==0
	
		eststo attrition_DW_bycomp: reg attrition_endline1 treat_dw_hom_blue treat_dw_mix if forced_type==0 & forced_comp==0 & treat_control_sbd_study2==0
		
		esttab attrition_DW attrition_DW_bycomp using "Output/attrition_DW_bycomp_combined.tex", replace ///
			label booktabs b(3) se(3) eqlabels(none) br nonotes nocons
							
		restore

	* Preferences for future outparty interactions, DW only and DW by composition, multinomial
	
	*Appendix Figure A.8 (appendix p. 23)
		mlogit cross_grouppref treat_control_dw_study2 BA_listserv i.partyID_merged if forced_type==0 & treat_control_sbd_study2==0
			margins, dydx(treat_control_dw_study2) post
			margins, coeflegend

			coefplot (, keep(treat_control_dw_study2:*._predict) label(Any DW) graphr(color(white)) ciopts(lcolor(black) lpattern(solid)) mcolor(black) msymbol(square)), ///
					vertical swapnames yline(0, lcolor(black)) legend(rows(2)) scheme(plotplain) ///
					xtitle("Preferences for future group contact", margin(medsmall)) xlabel(1 "Inparty only" 3 "Outparty only" 5 "Mixed" , angle(horizontal)) ///
					ytitle("Change in predicted probability", margin(medsmall) size(medium)) ylabel(-.2(.1).2)

					gr_edit .xaxis2.draw_view.setstyle, style(no)

						graph export "Output/cross_grouppref_DW_1.pdf", as(pdf) replace
	*Appendix Figure A.9 (appendix p. 23)
	
		mlogit cross_grouppref treat_dw_hom_blue treat_dw_mix BA_listserv i.partyID_merged if forced_type==0 & forced_comp==0 & treat_control_sbd_study2==0
			margins, dydx(treat_dw_hom_blue treat_dw_mix) post
			margins, coeflegend

			coefplot (, keep(treat_dw_hom_blue:1._predict) label(Homogeneous DW) graphr(color(white)) ciopts(lcolor(black) lpattern(longdash)) mcolor(black) msymbol(circle) offset(1)) ///
				(, keep(treat_dw_hom_blue:2._predict) label(Homogeneous DW) graphr(color(white)) ciopts(lcolor(black) lpattern(longdash)) mcolor(black) msymbol(circle) offset(3.5)) ///
				(, keep(treat_dw_hom_blue:3._predict) label(Homogeneous DW) graphr(color(white)) ciopts(lcolor(black) lpattern(longdash)) mcolor(black) msymbol(circle) offset(6)) ///			
				(, keep(treat_dw_mix:1._predict) label(Mixed DW) graphr(color(white)) ciopts(lcolor(black) lpattern(shortdash)) mcolor(black) msymbol(triangle) offset(8)) ///
				(, keep(treat_dw_mix:2._predict) label(Mixed DW) graphr(color(white)) ciopts(lcolor(black) lpattern(shortdash)) mcolor(black) msymbol(triangle) offset(10.5)) ///
				(, keep(treat_dw_mix:3._predict) label(Mixed DW) graphr(color(white)) ciopts(lcolor(black) lpattern(shortdash)) mcolor(black) msymbol(triangle) offset(13)), ///
					vertical swapnames yline(0, lcolor(black)) legend(rows(2) order(2 "Homogeneous DW" 8 "Mixed DW")) scheme(plotplain) ///
					xtitle("Preferences for future group contact", margin(medsmall)) xlabel(2 "Inparty only" 4.5 "Outparty only" 7 "Mixed" 10 "Inparty only" 12.5 "Outparty only" 15 "Mixed", angle(horizontal)) ///
					ytitle("Change in predicted probability", margin(medsmall) size(medium)) ylabel(-.4(.1).4)

						graph export "Output/cross_grouppref_DW_bycomp_1.pdf", as(pdf) replace
						
	* Antidemocratic attitudes, DW only and DW by composition
	
	*Appendix Figure A.11 (p.27)

		DW_bycomp_combined antidem_idx, ctrls(i.partyID_merged BA_listserv) newctrls(BA_listserv) outcome(antidemocratic attitudes) xmin(-.5) xmax(.5) xdelta(.25) wave(1)

	* Tolerance for racism and misinformation, DW only and DW by composition
	
	*Appendix figure A.12

		DW_bycomp_combined tol_rac_mis_idx, ctrls(i.partyID_merged BA_listserv) newctrls(BA_listserv) outcome(tolerance for racism and misinformation) xmin(-.5) xmax(.5) xdelta(.25) wave(1)
					
								
* Run robustness checks

	* Test whether respondents who were available on DW dates are statistically different from respondents who were available on SBD dates in the control group
	
	*Appendix Table A.13 (appendix p. 21)

		preserve
		
		la var aff_pol_idx_noneg "\shortstack{Attitudinal\\affective polarization}"
		la var aff_pol_idx_noneg_out "\shortstack{Affective\\polarization (out-)\\party animus only}"
		la var sbd_march5_march19 "Available on SBD dates"
		la var dw_march12_march26 "Available on DW dates"
		la var partyID_endline1 "Republican"
		la var BA_listserv "BA sample"

		eststo robust_available: reg aff_pol_idx_noneg sbd_march5_march19 dw_march12_march26 i.partyID_merged BA_listserv if treat_control_study2==0 & forced_type==0
			test sbd_march5_march19 = dw_march12_march26
		eststo robust_available_out: reg aff_pol_idx_noneg_out sbd_march5_march19 dw_march12_march26 i.partyID_merged BA_listserv if treat_control_study2==0 & forced_type==0
			test sbd_march5_march19 = dw_march12_march26
			esttab robust_available robust_available_out using "Output/robust_available.tex", replace ///
				label booktabs b(3) se(3) eqlabels(none) br nonotes nocons drop(0.partyID_merged)
				
		restore
	
	* Test for differential treatment effects by earlier and later workshop dates
	
	*Appendix Table A.14 (appendix p. 25)

		preserve

		la var aff_pol_idx_noneg "\shortstack{Attitudinal\\affective polarization}"
		la var aff_pol_idx_noneg_out "\shortstack{Affective\\polarization (out-)\\party animus only}"
		la var treat_march5_12 "Assigned to earlier workshop dates"
		la var treat_march19_26 "Assigned to later workshop dates"

		eststo robust_timing: reg aff_pol_idx_noneg treat_march5_12 treat_march19_26 i.partyID_merged BA_listserv if forced_type==0
		eststo robust_timing_out: reg aff_pol_idx_noneg_out treat_march5_12 treat_march19_26 i.partyID_merged BA_listserv if forced_type==0
			esttab robust_timing robust_timing_out using "Output/robust_timing.tex", replace ///
				label booktabs b(3) se(3) eqlabels(none) br nonotes nocons drop(0.partyID_merged)
	
		restore
	


	* Estimate ITTs on SBD and DW skills, disaggregating by workshop type; alternative 4-category measure
	
*Appendix Figure A.10 (appendix p. 26)	
								
mlogit dw_skills_uptake_multi i.treat_control_type_study2 i.partyID_merged BA_listserv if forced_type==0 [pweight = type_ipw], base(4)	
			margins, dydx(i.treat_control_type_study2) post
				coefplot (, keep(*:1._predict) label(Acknowledges personal depolarization) graphr(color(white)) ciopts(lcolor(black) lpattern(solid)) mcolor(black) msymbol(square)) ///
					(, keep(*:2._predict) label(Corrects misperception of outgroup) graphr(color(white)) ciopts(lcolor(black) lpattern(shortdash)) mcolor(black) msymbol(triangle))   ///
					(, keep(*:3._predict) label(Hears and acknowledges speaker) graphr(color(white)) ciopts(lcolor(black) lpattern(longdash)) mcolor(black) msymbol(circle)) ///
					, vertical swapnames yline(0, lcolor(black)) legend(rows(3)) scheme(plotplain) ///
					xtitle("", margin(medsmall)) xlabel(1 "SBD" 2 "DW", angle(horizontal)) xscale(range(0.5 2.5)) ///
					ytitle("Change in predicted probability", margin(medsmall) size(medium)) ylabel(-.2(.1).2) ///
					title(DW Skills Scenario) name(dw_skills_bytype2, replace) legend(pos(6))
						
mlogit sbd_skills_uptake_multi i.treat_control_type_study2 i.partyID_merged BA_listserv if forced_type==0 [pweight = type_ipw], base(4)							
			margins, dydx(i.treat_control_type_study2) post
				coefplot (, keep(*:1._predict) label(Hears and acknowledges speaker) graphr(color(white)) ciopts(lcolor(black) lpattern(solid)) mcolor(black) msymbol(square)) ///
					(, keep(*:2._predict) label(Restates extreme version of point) graphr(color(white)) ciopts(lcolor(black) lpattern(shortdash)) mcolor(black) msymbol(triangle))   ///
					(, keep(*:3._predict) label(Corrects misperception) graphr(color(white)) ciopts(lcolor(black) lpattern(longdash)) mcolor(black) msymbol(circle)) ///
					, vertical swapnames yline(0, lcolor(black)) legend(rows(3)) scheme(plotplain) ///
					xtitle("", margin(medsmall)) xlabel(1 "SBD" 2 "DW", angle(horizontal)) xscale(range(0.5 2.5)) ///
					ytitle("Change in predicted probability", margin(medsmall) size(medium)) ylabel(-.2(.1).2) ///
					title(SBD Skills Scenario) name(sbd_skills_bytype2, replace) legend(pos(6))
					
			graph combine dw_skills_bytype2 sbd_skills_bytype2, ycommon xcommon scheme(plotplain) col(2) name(dw_sbd_skills_bytype2, replace)
					graph export "Output/dw_sbd_skills_bytype2.pdf", as(pdf) replace
								
	* Balance using Qualtrics and endline surveys

	*Appendix table A.7 (appendix p. 14)
	
		preserve
	
		la var BA_listserv "BA listserv"
		la var partyID_merged_D "Democrat"
		la var partyID_merged_R "Republican"
		la var age "Age"
		la var gender_endline1_m "Male"
		la var ethnicity_white "White"
		la var ethnicity_black "Black"
		la var ethnicity_hispanic "Hispanic/Latino"
		la var ethnicity_asian "Asian"
		la var previous_BA_any "Attendance at past BA events"
		
		eststo treat_control_Q: reg treat_control_study2 BA_listserv partyID_merged_D partyID_merged_R previous_BA_any
			local F_stat_Q = round(e(F),.001)	
			
		eststo treat_control_Q_end: reg treat_control_study2 BA_listserv partyID_merged_D partyID_merged_R previous_BA_any age gender_endline1_m ethnicity_white ethnicity_black ethnicity_hispanic ethnicity_asian
			local F_stat_Q_end = round(e(F),.001)	
		
		esttab treat_control_Q treat_control_Q_end using "Output/balance_Qualtrics_endline.tex", replace ///
			label booktabs b(3) se(3) eqlabels(none) br nonotes nocons star(* 0.10 ** 0.05 *** 0.01) ///
			nomtitle collabels(none) mgroups("Assigned to treatment", pattern(1 0) ///
			prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))

		
		restore
		

			* Descriptive statistics
			
			*Appendix Table A.5 (appendix p.11)
				
		preserve
		
		append using "Data/Raw/anes_timeseries_cdf_stata_20211118_clean.dta"
		
		la var partyID_merged_D "Democrat"
		la var partyID_merged_R "Republican"
		la var partyID_merged_I "Independent"
		la var age "Age"
		la var gender_endline1_m "Male"
		la var gender_endline1_f "Female"
		la var ethnicity_white "White"
		la var ethnicity_black "Black"
		la var ethnicity_hispanic "Hispanic/Latino"
		la var ethnicity_asian "Asian"
		la var therm_outparty "Out-party warmth"
		la var therm_inparty "In-party warmth"
		la var BA_listserv "BA listserv"
		la var L2_database "L2 database"
				
		estpost summarize partyID_merged_D partyID_merged_R partyID_merged_I age gender_endline1_m gender_endline1_f ethnicity_white ethnicity_black ethnicity_hispanic ethnicity_asian therm_outparty therm_inparty BA_listserv L2_database if ANES!=1
			eststo summstats_all

		estpost summarize partyID_merged_D partyID_merged_R partyID_merged_I age gender_endline1_m gender_endline1_f ethnicity_white ethnicity_black ethnicity_hispanic ethnicity_asian therm_outparty therm_inparty if BA_listserv==0 & ANES!=1
			eststo summstats_L2

		estpost summarize partyID_merged_D partyID_merged_R partyID_merged_I age gender_endline1_m gender_endline1_f ethnicity_white ethnicity_black ethnicity_hispanic ethnicity_asian therm_outparty therm_inparty if BA_listserv==1 & ANES!=1
			eststo summstats_BA

		estpost summarize partyID_merged_D partyID_merged_R partyID_merged_I age gender_endline1_m gender_endline1_f ethnicity_white ethnicity_black ethnicity_hispanic ethnicity_asian therm_outparty therm_inparty if ANES==1
			eststo summstats_ANES

		esttab summstats_all summstats_L2 summstats_BA summstats_ANES using "Output/summstats.tex", replace ///	
			booktabs cell((mean(label(Mean) fmt(%9.2f)) sd(label(S.D.) fmt(%9.2f)) count(label(N) fmt(%9.0f)))) eqlabels(none) nomtitle noobs nonumber nonotes label ///
			mgroups("Full sample" "L2 database" "BA listserv" "ANES", pattern(1 0 0 1 0 0 1 0 0 1 0 0) ///
			prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))
			

		drop if ANES==1
			 
		restore	
